﻿namespace CRMG.Container.Source.OpManager
{
    using CRMG.Container.Source.BO;
    using CRMG.Container.Source.DL;
    using CRMG.Container.Source.Variables;
    using CRMG.ResourceManagement.Resources;
    using Guru.ErrorHandling;
    using System;
    using System.Data;

    public class PaymentManager
    {
        public DataTable GetPaymentsOfStudent(int studentId)
        {
            try
            {
                InPaymentDL payDL = new InPaymentDL();
                return payDL.GetPaymentsOfStudent(studentId);
            }
            catch (Exception exc)
            {
                LogEntry logger = new LogEntry(AppVariables.CurrentUser.OBJID)
                {
                    ErrorCode = 2101,
                    Title = Rc.GetString(2101)
                };
                throw new GuruException(exc, logger);
            }
        }

        #region [ GetBillTypes method ]

        public DataTable GetBillTypes()
        {
            try
            {
                BillTypeDL btypeDL = new BillTypeDL();
                return btypeDL.GetTable(new BillType());
            }
            catch (Exception exc)
            {
                LogEntry logger = new LogEntry(AppVariables.CurrentUser.OBJID)
                {
                    ErrorCode = 2083,
                    Title = Rc.GetString(2083)
                };
                throw new GuruException(exc, logger);
            }
        }

        #endregion


        #region [ GetPaymentTypes method ]

        public DataTable GetPaymentTypes()
        {
            try
            {
                PaymentTypeDL ptypeDL = new PaymentTypeDL();
                return ptypeDL.GetTable(new PaymentType());
            }
            catch (Exception exc)
            {
                LogEntry logger = new LogEntry(AppVariables.CurrentUser.OBJID)
                {
                    ErrorCode = 2059,
                    Title = Rc.GetString(2059)
                };
                throw new GuruException(exc, logger);
            }
        }

        #endregion


        #region [ AddPayment method ]

        public int AddPayment(InPayment pInPayment)
        {
            try
            {
                InPaymentDL inpDL = new InPaymentDL();
                return inpDL.InsertAndGetId(pInPayment);
            }
            catch (Exception exc)
            {
                LogEntry logger = new LogEntry(AppVariables.CurrentUser.OBJID)
                {
                    ErrorCode = 2060,
                    Title = Rc.GetString(2060)
                };
                throw new GuruException(exc, logger);
            }
        }

        #endregion


        #region [ GetPayments method ]

        public DataTable GetPayments()
        {
            try
            {
                InPaymentDL inpDL = new InPaymentDL();
                return inpDL.GetPayments();
            }
            catch (Exception exc)
            {
                LogEntry logger = new LogEntry(AppVariables.CurrentUser.OBJID)
                {
                    ErrorCode = 2069,
                    Title = Rc.GetString(2069)
                };
                throw new GuruException(exc, logger);
            }
        }

        #endregion
    }
}
